//
//  YDUserSettingTableViewCell.m
//  IngCard
//
//  Created by kf on 2017/8/9.
//  Copyright © 2017年 IngDan. All rights reserved.
//

#import "YDUserSettingTableViewCell.h"


@implementation  YDUserSettingCellDataSource
-(Class) viewClass
{
    return [YDUserSettingTableViewCell class];
}

@end

@interface YDUserSettingTableViewCell()
@property(nonatomic, strong) UILabel *titleLabel;
@property(nonatomic, strong) UIImageView *accessImageView;
@property(nonatomic, strong) UIView *separatorLine;

@end

@implementation YDUserSettingTableViewCell

+(CGFloat)viewHeight:(YDUserSettingCellDataSource *) dataSource
{
    return dataSource.height ?: 45;
}

-(void) initSubviews
{
    [super initSubviews];
    
    [self.contentView addSubview:self.titleLabel];
    [self.titleLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(36);
        make.width.equalTo(200);
        make.bottom.equalTo(self.contentView.mas_bottom).offset(-10);
    }];
    
    [self.contentView addSubview:self.accessImageView];
    [self.accessImageView makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView).offset(-50);
        make.bottom.equalTo(self.contentView.mas_bottom).offset(-10);
    }];
    
    [self.contentView addSubview:self.separatorLine];
    [self.separatorLine makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(30);
        make.right.equalTo(self.contentView).offset(-36);
        make.bottom.equalTo(self.contentView);
        make.height.equalTo(1);
    }];
}

-(void) onViewModelChanged
{
    YDUserSettingCellDataSource *dataSource = (YDUserSettingCellDataSource *)self.dataSource;
    if (dataSource)
    {
        self.titleLabel.text = dataSource.title;
    }
}

#pragma mark - lazy loading

-(UILabel *) titleLabel
{
    if (!_titleLabel)
    {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.text = @"姓名";
        _titleLabel.textAlignment = NSTextAlignmentLeft;
        _titleLabel.font = UIFontBoldMake(18);
        _titleLabel.textColor = UIColorMake(3, 3, 3);
    }
    return _titleLabel;
}

- (UIImageView *) accessImageView
{
    if (!_accessImageView)
    {
        _accessImageView = [UIImageView new];
        _accessImageView.image = TableViewCellDisclosureIndicatorImage;
        _accessImageView.contentMode = UIViewContentModeCenter;
    }
    return _accessImageView;
}

-(UIView *)separatorLine
{
    if (!_separatorLine)
    {
        _separatorLine = [[UIView alloc] init];
        _separatorLine.backgroundColor = UIColorMake(200, 199, 204);
    }
    return _separatorLine;
}

@end
